package com.lwlean.test.aliyun.oss;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * Created by lean on 2016/12/22.
 */
@Component
@Configuration
public class OSSConfiguration {

    private static final Logger log = LoggerFactory.getLogger(OSSConfiguration.class);

    @Value("${endpoint}")
    private String endpoint;

    @Value("${accessKeyId}")
    private String accessKeyId;

    @Value("${accessKeySecret}")
    private String accessKeySecret;

    @Value("${bucketName}")
    private String bucketName;

    @Bean
    public OSS getOSS(){
//        final OSS oss = new OSS();
//        final OSSClient ossClient = new OSSClient(endpoint,accessKeyId,accessKeySecret);
//        if(ossClient!=null){
//            final Bucket bucket = ossClient.createBucket(bucketName);
//            oss.setOssClient(ossClient);
//            oss.setBucket(bucket);
//            return oss;
//        }
        log.error("create OSSClient failed by endpoint:{} and accessKeyId:{} and accessKeySecret:{}",endpoint,accessKeyId,accessKeySecret);
        return null;

    }

}
